set backed_up_file [lindex $argv 0]
set current_time [clock seconds]
set suffix [clock format $current_time -format {_%m%d_%H%M}]
if {[file tail [info script]] eq $backed_up_file} {
    error "File was not selected correctly from eclipse"
} elseif {![file exists $backed_up_file]} {
    error "File does not exist!\n\
           Current Working Directory is \"[pwd]\""
} else {
    if {![file exists BackUps]} {
        file mkdir BackUps
    } elseif {![file isdirectory BackUps]} {
        error "Cannot create directory named \"BackUps\", a file with the same\
               name already exists"
    }
    set backup_folder [file join BackUps $backed_up_file]
    if {![file exists $backup_folder]} {
        file mkdir $backup_folder
    } elseif {![file isdirectory $backup_folder]} {
        error "Cannot create directory named \"$backed_up_file\" in \
               \"BackUps\" folder, a file with the same name already exists"
    }
    if {[regexp {(.*)(\.[^.]*?)$} $backed_up_file dummy file_name file_ext]} {
        set copy_path [file join $backup_folder $file_name$suffix$file_ext]
    } else {
        set copy_path [file join $backup_folder $backed_up_file$suffix]
    }
    file copy -force $backed_up_file $copy_path
    file attributes $copy_path -readonly true
    puts "File Copied to \"$copy_path\" Successfully"
}
